﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Maticsoft.DBUtility;

namespace ZG_member.DAL
{
    public class Duanxingneirong
    {
        public bool update(int id,string neirong) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update Duanxingneirong set ");
            strSql.Append("fasongneirong=@fasongneirong,");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
					new SqlParameter("@fasongneirong", SqlDbType.NVarChar,500),
					new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = neirong;
            parameters[1].Value = id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public Model.Duanxingneirong getmodel(int id) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *");
            strSql.Append(" FROM Duanxingneirong where id = " +id);
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            ZG_member.Model.Duanxingneirong model = new ZG_member.Model.Duanxingneirong();
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["fasongneirong"] != null && ds.Tables[0].Rows[0]["fasongneirong"].ToString() != "")
                {
                    model.Fasongneirong = ds.Tables[0].Rows[0]["fasongneirong"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

    }
}
